#include<bits/stdc++.h>
#define s(a) scanf("%d",&a)
using namespace std;
int T,n,m,L,ans,vv;
bool b[100010];
double s[100010],d[100010],vs[100010],a[100010],v;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--)
    {
        ans=0;
        s(n);s(m);s(L);s(vv);
        v=double(vv);
        for(int i=1;i<=n;i++)
        {
            int x,y,z;
            s(x);s(y);s(z);
            d[i]=double(x);
            vs[i]=double(y);
            a[i]=double(z);
        }

        for(int i=1;i<=m;i++)
        {
            int ss;
            s(ss);
            s[i]=double(ss);
        }
        for(int i=1;i<=n;i++)
        {
            if(a[i]==0)
            {
                if(vs[i]<v) continue;
                if(d[i]<=s[m]&&vs[i]>v) {ans++;continue;}
                continue;
            }
            if(vs[i]>v)
            {
                if(d[i]<=s[m]) ans++;
                continue;
            }
            double dis=(double(v*v)-double(vs[i]*vs[i]))/double(2.0*a[i]);
            double r=double(d[i]+dis);
            if(r>=s[m]) continue;
            ans++;

        }
        if(ans==0) cout<<0<<" "<<m<<endl;
        else cout<<ans<<" "<<m-1<<endl;
    }

    return 0;
}
